package com.jy.adscm.wechat.controller;


import com.jy.adscm.exception.AdscmSystemException;
import com.jy.adscm.support.SimpleCoreResponse;
import com.jy.adscm.utils.AdscmBaseUtils;
import com.jy.adscm.wechat.bean.WechatRole;
import com.jy.adscm.wechat.bean.WechatUser;
import com.jy.adscm.wechat.bean.WechatUserRole;
import com.jy.adscm.wechat.service.WechatUserRoleService;
import com.jy.adscm.wechat.utils.RedisOperator;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author zyl
 * @since 2019-09-24
 */
@RestController
@RequestMapping("adscm/wechat/wechatRole")
public class WechatRoleController {
    @Autowired
    private RedisOperator redis;
    @Autowired
    WechatUserRoleService wechatUserRoleService;
    @RequestMapping("selectRolesBySessionKey")
    public SimpleCoreResponse selectBySessionKey(HttpServletRequest request)throws AdscmSystemException {
        String sessionKey = request.getParameter("sessionKey");
        String openid = redis.get(sessionKey);

        List<WechatRole> wechatroles  =  wechatUserRoleService.selectByOpenId(openid);
        return  new SimpleCoreResponse("200","新增成功",wechatroles);
    }
}

